#include <stdio.h>
#include <stdlib.h>
#include "E:\Desktop\data_struct\5TREE\1_bin_tree\creat.h"
tree *fun(tree *root)
{
    tree *stack[100], *new_root = NULL, *pre, *t;
    int top = -1;
    t = root;
    while (t || top >= 0)
    {
        while (t)
        {
            stack[++top] = t;
            t = t->left;
        }
        if (top >= 0)
        {
            t = stack[top--];
            if (!new_root)
                new_root = t;
            else
            {
                pre->left = NULL;
                pre->right = t;
            }
            pre = t;
            t = t->right;
        }
    }
    pre->left = NULL;
    return new_root;
}

int main()
{
    /*******************code*******************/
    tree *root;
    int a[] = {5, 3};
    CreatTree(root, a, 2, 0);
    tree *n = fun(root);
    /******************************************/
    fflush(stdin);

    printf("\n\n****************************\n");
    printf("Press Enter key to continue\n");
    getchar();
    return 0;
    /******************************************/
}
